package com.example.chiffreetdeslettre;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;

public class SplashScreenActivity extends Activity {
	Handler h = new Handler();
	MediaPlayer player;
	private static Context c;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		c = this.getApplicationContext();
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		// Ton layout ecran accueil
		setContentView(R.layout.activity_splashscreen);
		Dictionnaire.getInstance();
		// Read the music file from the asset folder
		player = new MediaPlayer();
		player = MediaPlayer.create(this, R.raw.generique);
		// Set the looping and play the music.
		player.start();
		//On appelle la fonction fonctionRun apres 7300 ms
		h.postDelayed(fonctionRun, 7300);

	}

	public static Context getC() {
		return c;
	}

	private Runnable fonctionRun = new Runnable() {
		@Override
		public void run() {
			Intent i = new Intent(SplashScreenActivity.this, MainActivity.class);
			startActivity(i);
			finish();
		}
	};

	protected void onStop() {
		super.onStop();
		player.stop();
		player = null;
	}

	public void onPause() {
		super.onPause();
		player.pause();
	}

	public void onResume() {
		super.onResume();
		player.start();
	}
}
